package mvc.util;

import java.io.File;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class XMLUtil {

public static String getBasePakage(String xmlPath){
	SAXReader reader = new SAXReader();
	String basePackage = "";
	try {
		Document doucument = reader.read(new File(xmlPath));
		Element element = doucument.getRootElement();
		Element amap = element.element("component-scan");
		basePackage = amap.attributeValue("basepackage");
		return basePackage;
		
	} catch (DocumentException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		System.out.println("mvc.xml加载失败！");
	}
	return basePackage;
}
public static void main(String[] args) {
	String basePackage = XMLUtil.getBasePakage("F:\\worke\\workspace\\mvc_t\\WebContent\\WEB-INF\\mvc.xml");
	System.out.println(basePackage);
}
}
